fix(codegen): lineage table CHECK refuses self-references#78
Merged
Conversation
Closes #42. `verisimdb_lineage_graph` had no constraint preventing `(source_entity, source_table) == (target_entity, target_table)`. Any row inserted with matching source/target tuples is a self-loop and falsifies the README's "DAG" framing at the structural level. Add a CHECK constraint: CHECK (source_entity <> target_entity OR source_table <> target_table) i.e. at least one component of the (entity, table) pair must differ. Two entities with the same id across different tables (a legitimate cross-table derivation) still pass. Multi-hop cycle prevention is a runtime concern (any number of CHECKs can't catch chains); kept as a separate follow-up (V-L2-I2). Test `test_lineage_table_has_self_reference_check` asserts the exact CHECK clause appears in the emitted DDL with lineage enabled. `cargo clippy --all-targets -- -D warnings` clean; 35 unit tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per V-L2-I1: lineage edges accepted
source == target, so the README's DAG claim was unenforced at the structural level. Add CHECK:Multi-hop cycle prevention is a runtime concern (tracked as the V-L2-I2 follow-up).
Closes
Test plan
cargo clippy --all-targets -- -D warningscleancargo test --lib --bins35/35 (1 new:test_lineage_table_has_self_reference_check)